Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

read-file-relative

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

read-file-relative

Read files with path relative to the current module without annoying boilerplate code

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
130K
decreased by-26.53%
Maintainers
1
Weekly downloads
 
Created

What is read-file-relative?

The read-file-relative npm package allows you to read files relative to the current module or process's current working directory. It simplifies the process of accessing files without needing to construct absolute paths manually.

What are read-file-relative's main functionalities?

Read file relative to the current module

This feature allows you to read a file relative to the current module's location. The `readSync` method reads the file synchronously.

const readFileRelative = require('read-file-relative');

readFileRelative.readSync('./relative/path/to/file.txt');

Read file relative to the current working directory

This feature allows you to read a file relative to the current working directory. The `readSyncFromCwd` method reads the file synchronously.

const readFileRelative = require('read-file-relative');

readFileRelative.readSyncFromCwd('./relative/path/to/file.txt');

Asynchronous file reading

This feature allows you to read a file asynchronously relative to the current module's location. The `read` method reads the file asynchronously and provides a callback for handling the file content or errors.

const readFileRelative = require('read-file-relative');

readFileRelative.read('./relative/path/to/file.txt', (err, content) => {
  if (err) throw err;
  console.log(content);
});

Asynchronous file reading from current working directory

This feature allows you to read a file asynchronously relative to the current working directory. The `readFromCwd` method reads the file asynchronously and provides a callback for handling the file content or errors.

const readFileRelative = require('read-file-relative');

readFileRelative.readFromCwd('./relative/path/to/file.txt', (err, content) => {
  if (err) throw err;
  console.log(content);
});

Other packages similar to read-file-relative

Keywords

FAQs

Package last updated on 06 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc